clear all

% data in the cell array )positions of x and y) always comes modified and arranged for the labels
% alignement; the label for the stimulus is now the one defined by the experiment and the
% same for all for it to be aligned
% NOTE: CHANGE NAMES AT LINES 13, 16, 17, 51,

%%
% Extra functions
%velocidadef

%% call the values of speed, x and y
speedall = xlsread ('RRF3_exp30_ZC2834_speed_all_F1');%all the individuals to make the scale

%% extract the values of x and y
load ('C:\Users\Ana\Dropbox\Matlab\data\matlab data\RRF3_exp30_ZC2834_F1\RRF3_exp30_ZC2834_PA choice OP\RRF3_exp30_ZC2834_PA_to_OP_F1.mat');
data = RRF3_exp30_ZC2834_PA_to_OP_F1;


speedrange = velocidadef (speedall);%extracts the minimum and maximum values of speed for this dataset
speedminall = speedrange (1,1);
speedmaxall = speedrange (1,2);

sujeitos = size (data,1)-1;% because it is counting with the label row
sujeitosloop = sujeitos + 1;

for i=2:sujeitosloop;
    speed = data (i,5);
    speedvalues = speed {1,1};
    speedNorm = (speedvalues - speedminall) / ( speedmaxall - speedminall) ; %Normalizes the values so that they fit in a color scale
    
    xpos = data (i, 17);
    xposvalues = xpos {1,1};
    
    ypos = data (i, 18);
    yposvalues = ypos {1,1};
    
    center = [17500, 12500];
    radius = (2000);
figure
%subplot (2,3, i);
viscircles (center, radius, 'Color', 'k');
hold on
% our plot with the coordinates x and y, size of dots 10 and color based on
% our heat map
scatter(xposvalues,yposvalues,10,speedNorm, 'filled')
colormap('jet')
box off
axis ([0,25000, 0, 25000]);
axis square
s1 = 'PA to OP Worm';
s2 = data (i, 1);
s2val = s2{1,1};
s3 = num2str(s2val);
name = strcat(s1,s3);
title(name)
xlabel ('x')
ylabel ('y')

%%  make the scale
speed0 = speedNorm (1,1); %find the value of 0 when normalized; 1st colum 1st row 
%because in the speed values the first values are always speed = 0
c = colorbar;
c.Label.String = 'Speed (um/s)';
caxis([0 1.0])% our speed is normalized from 0 to 1 so will match the scale
colorbar('Ticks',[0,speed0,1.0],...
         'TickLabels',{speedminall,0,speedmaxall});    
hold on;
end


